package com.calcgpa.core;

import java.util.List;

import com.calcgpa.core.vo.Score;
import com.calcgpa.core.vo.User;


public class CalcGPAForSwing extends CalcGPA {
	
	/**
	 * The calc method for swing client.
	 * @param username
	 * @param password
	 * @param term
	 * @param scores
	 * @param user
	 * @return
	 */
	public int doCalc(String username, String password, String term, List<Score> scores, User user){
		init();
		if (doLogin(username, password) == LOGIN_ERROR) return LOGIN_ERROR;
		String response = doGetScores(1, term);
		if (response.indexOf("学生各类信息查询") != -1) return LOGIN_ERROR;
		List<Score> scores1 = analysisScore(response);
		analysisUser(response, user);
		scores.addAll(scores1);
		end();
		return SUCCESS;
	}
}
